/* Returns the number of one bits in the bitmatrix representation of n in GF(2^w) */
int CRS_N_Ones(int n, int w);

/* Returns a Vandermonde matrix as a matrix object. For Reed_Solomon coding. */
JER_Matrix *RS_Nonsystematic_Matrix(int n, int k, int w);
/* Returns a Vandermonde matrix inside a generator object. For Reed-Solomon
   coding. Calls RS_Nonsystematic_Matrix. */
JER_Gen_T *RS_Nonsystematic_Generator(int n, int k, int w);
/* Modifies a generator object to contain a nonsystematic matrix. */
int RS_Nonsystematic_Generator(int n, int k, int w, JER_Gen_T &g);

/* Returns a Vandermonde matrix that has been row reduced to contain an
   identity matrix in its first k rows. Returned as a matrix object. */
JER_Matrix *RS_Extended_Matrix(int k, int m, int w);
/* Returns a row reduced Vandermonde matrix as a generator object. */
JER_Gen_T *RS_Extended_Generator(int k, int m, int w);
/* Modifies a generator object to contain a row reduced Vandermonde matrix. */
int RS_Extended_Generator(int k, int m, int w, JER_Gen_T &g);

/* Returns a m x k matrix that corresponds to the coding rows of a systematic
   Reed-Solomon code. */
JER_Matrix *RS_Classic_Matrix(int k, int m, int w);
/* Returns a generator object that contains only the coding rows in its matrix. */
JER_Gen_T *RS_Classic_Generator(int k, int m, int w);
/* Modifes a generator object to do a systematic Reed-Solomon coding. */
int RS_Classic_Generator(int k, int m, int w, JER_Gen_T &g);

/*Returns a generator object for RAID6 Reed-Solomon coding. */
JER_Gen_T *RS_R6_Generator(int k, int w);
/* Modifies a generator object for RAID6 Reed-Solomon coding. */
int RS_R6_Generator(int k, int w, JER_Gen_T &g);

/* Returns a generator object that contains a Cauchy matrix for Reed-Solomon 
   coding. */
JER_Gen_T *CRS_Generator(int k, int m, int w);
/* Modifies a generator object to contain a Cauchy matrix for Reed-Solomon coding. */
int CRS_Generator(int k, int m, int w, JER_Gen_T &g);

/* Returns a generator object with a Cauchy matrix created by using sets X and Y. */ 
JER_Gen_T *CRS_XY_Generator(int k, int m, int w, vector <int> &X, vector <int> &Y);
/* Modifies a generator object to contain a Cauchy matrix from sets X and Y. */
int CRS_XY_Generator(int k, int m, int w, vector <int> &x, vector <int> &Y, JER_Gen_T &g);

/* Row reduces a Cauchy matrix held by g to minimize the number of ones in its 
   bitmatrix representation. */
int CRS_Improve_Generator(JER_Gen_T *g);

/* Obsolete because of JER_Gen_T::Genmatrix_To_Genbitmatrix */
JER_Gen_T *CRS_Convert_To_Bitmatrix(JER_Gen_T *g);
int CRS_Convert_To_Bitmatrix(JER_Gen_T &g);

/* Performs CRS_Generator, CRS_Improve, and Convert. Either returns Gen_T object
   or modifies it. */
JER_Gen_T *CRS_Good_Generator_Bitmatrix(int k, int m, int w);
int CRS_Good_Generator_Bitmatrix(int k, int m, int w, JER_Gen_T &g);
